/*
 * Access_attributes.h
 *
 *  Created on: 10.08.2011
 *      Author: mario
 */

#ifndef ACCESS_ATTRIBUTES_H_
#define ACCESS_ATTRIBUTES_H_

#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/property_tree/ptree.hpp>
#include "stdint.h"

using namespace std;

using boost::property_tree::ptree;


class Access_attributes
{
public:
    typedef uint8_t ACCESS_RIGHTS;
    static const ACCESS_RIGHTS NONE = 0;
    static const ACCESS_RIGHTS PULL = 1;
    static const ACCESS_RIGHTS DOWNLOAD_ONCE = 2;


    Access_attributes();
    Access_attributes(string path, ACCESS_RIGHTS privileges);
    Access_attributes(ptree &pt);
    virtual ~Access_attributes();


    string get_path() const
    {
        return path;
    }

    void update_privileges(ACCESS_RIGHTS privileges);
    void add_privilege(ACCESS_RIGHTS privilege);
    bool has_privilege(ACCESS_RIGHTS privileges);

    void save(ptree &pt);


private:
    string path;
    ACCESS_RIGHTS privileges;
};

typedef boost::shared_ptr<Access_attributes> AccessPtr;

#endif /* ACCESS_ATTRIBUTES_H_ */
